import { formatDate } from "@/utils/common.js";
let data =[]
let area = ['雨城区','天全县','荥经县','庐山区']
let pro = [1,2,3]
let water_level = []
let io = 1
for(var i = 1;i<=20;i++){
    createdData(setDate())
}
// 创建一个数据
function createdData(cur_t){
    var level = parseInt(Math.random()*80)
    if(setDataStatus()) {
        data.unshift({
            date: cur_t,
            name: '设备' + io,
            area_name: area[Math.floor((Math.random() * area.length))],
            p_name: '项目' + pro[Math.floor((Math.random() * pro.length))],
            cstype: '机器检测',
            jobnumber: 'sl0000' + (io),
            gate: parseInt(Math.random() * 50),
            water_level: level + 500,
            water_standard: 580,
            water_number: level + 400,
            water_number_: 480,
            flow: parseInt(Math.random() * 50),
            status: level + 500 > 580 ? '水位预警' : (level + 400 > 480 ? '流量报警' : '正常'),
            mark: '设备运行正常，正常采集中'
        })
    }else{
        data.unshift({
            date: cur_t,
            name: '设备' + io,
            area_name: '/',
            p_name: '/',
            cstype: '/',
            jobnumber: '/',
            gate: '/',
            water_level: '/',
            water_standard: '/',
            water_number: '/',
            water_number_: '/',
            flow: '/',
            status: '/',
            mark: '通讯异常，采集失败'
        })
    }
    io++;
}

function setDate(){
    return formatDate(new Date(new Date().getTime()-parseInt(Math.random()*60*60*1000)), "yyyy-MM-dd hh:mm:ss")
}
// 数据状态
function setDataStatus(){
    return parseInt(Math.random() * 10) < 2 ? false : true;
}
export default data